/*
 * @Author: your name
 * @Date: 2021-11-01 09:29:48
 * @LastEditTime: 2021-11-02 20:47:58
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \练习\snake\src\game\index.ts
 */
import { IsLive, Map } from '@/types';
import { GameControl } from './GameControl'
import { initMap } from './map'
let gameControl: GameControl
// 初始化游戏
export function initGame(map: Map, isLive: IsLive) {
	gameControl = new GameControl(initMap(map), isLive)
}
// 开始游戏
export function startGame() {
	gameControl.start()
}
// 重新开始游戏
export function replayGame() {
	gameControl.replay()
}
// 移动端修改移动方向
export function changeMoveDirection(x: number, y: number) {
	gameControl.snake.chengeMoveDirection(x, y);
}

// 移动端修改移动方向
export function changeDirection(direction: string) {
	gameControl.snake.chengeDirection(direction);
}